-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Resampling Support #1180
base: dev
Are you sure you want to change the base?
Add Resampling Support #1180
Conversation
838855b
to
fdd44c0
Compare
4b454f6
to
013f63a
Compare
@eladyn or @roderickvd or anyone else really, this could use a review. I know it's a lot of code, I tried my best to split it up into a few commits to make it comprehensible. |
It would be so much easier to use elapsed but elapsed could potentially panic is rare cases. See: https://doc.rust-lang.org/std/time/struct.Instant.html#monotonicity Otherwise this is pretty straight forward. If anything fails getting expected_position_ms it will return 0 which will trigger a notify if either stream_position_ms or decoder_position_ms is > 1000. If all goes well it's simply a matter of calculating the max delta of expected_position_ms and stream_position_ms and expected_position_ms and decoder_position_ms. So if the decoder or the sample pipeline are off by more than 1 sec we notify.
f4013f0
to
3411c41
Compare
Ok @roderickvd I've managed to generate anti-alias filters that are @ -0.5dB at 20kHz and @ -96dB at 22.05kHz using https://github.com/chipmuenk/pyfda The only catch is that there would end up being a 1200 line filter_coefficients.rs that contains all of coefficients as arrays. It does sound damn good though. |
Oh, I'm using a Kaiser Window with a beta of 8.6 so the lobe approximates a Blackman Window. |
All Windows calculated with pyfda (Python Filter Design Analysis Tool) https://github.com/chipmuenk/pyfda Window = Kaiser beta = 8.6 (Similar to a Blackman Window) fc = 22.5kHz -86dB by 23kHz This also gets rid of Linear Interpolation which leaves only Low and High both being Windowed Sinc.
I changed the filters a bit. I moved the fc up so that it won't cutoff any of the source. That will gives us -86dB before 23kHz. |
Do you have a graph? I think your previous one is more SOTA. Slight roll-off just around or before 20 kHz is very common in industry as you can see by the transition band figures I posted earlier. |
33225cc
to
6176710
Compare
So is that back to the first one you posted? Like you said then, you thought it sounded great, and objectively I think it looks like the best of them. |
No I have a better one. This one still hits your targets but it hits -135dB at around 23kHz. I also lengthened the window and narrowed the main lobe width to improve interpolation quality. It cost a tiny bit more CPU cycles by I think it's worth it. Sorry this is taking a lot of iterations to get right but it's really trial and error. |
I think -135dB is good enough. If I don't stop myself somewhere I'll be tweaking on this forever,lol!!! |
@roderickvd what I just pushed will get us flat until just over 20kHz and about -195dB before 22kHz. And since -195dB is below the noise floor of even S32 any aliasing artifacts should be buried in the noise floor/quantization noise. |
And it sounds good too? 😄 |
I'm still fine tuning. Since I don't have any way to objectively test anything and I can't really can't find any solid advice online specifically for interpolation kernels I'm left to do it by ear. I can find things specific to FIR filters but that advice does not necessary apply. I've been doing my testing in another branch so as not to spam the CI here. I'll let you know when I'm sure it's ready and even then I'd like at least one other person to listen to it to get their impression before it's merged. |
Any updates? |
6907ecd
to
8aaab0a
Compare
bump any updates? |
This PR adds resampling to 48kHz, 88.2kHz, and 96kHz with Windowed Sinc Interpolation.
It also moves everything except decoding out of
player
and a few other misc improvements like improving thread creation in player, using#[default]
in the player config enums where we can, and includes the sample pipeline latency in calculating an accurate position.